package com.gopay.scheduler.dao.impl;

import com.gopay.common.base.dao.impl.BaseDAOImpl;
import com.gopay.common.domain.cert.CertCustPolicyEntity;
import com.gopay.scheduler.dao.CertCustPolicyEntityDao;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by zhaojt on 2016/9/6.
 */
@Repository("certCustPolicyEntityDao")
public class CertCustPolicyEntityDaoImpl extends BaseDAOImpl<CertCustPolicyEntity, String> implements CertCustPolicyEntityDao {

    @Override
    public CertCustPolicyEntity findByCustId(String custId) {
        DetachedCriteria criteria = DetachedCriteria.forClass(CertCustPolicyEntity.class);
        criteria.add(Restrictions.eq("custId", custId));
        List<CertCustPolicyEntity> list = this.findByCriteria(criteria);
        return (list != null && list.size() > 0 ) ? list.get(0) : null;
    }
}
